package com.mvity.framework.common.dao;

import java.sql.SQLException;
import java.util.List;

import com.mvity.framework.common.base.BaseEntity;

/**
 * @author vity
 * @date 2012-7-23
 * @mail vity.1215@gmail.com
 */
public interface BaseJdbcDao {

	/**
	 * 查询指定的SQL
	 * 
	 * @param entityClass
	 * @param sql
	 * @return
	 * @throws SQLException
	 */
	public abstract <T extends BaseEntity> List<T> executeQuerySQL(Class<T> entityClass, String sql) throws SQLException;

	/**
	 * 查询指定SQL
	 * 
	 * @param entityClass
	 * @param sql
	 * @param params
	 * @return
	 * @throws SQLException
	 */
	public abstract <T extends BaseEntity> List<T> executeQuerySQL(Class<T> entityClass, String sql, Object[] params) throws SQLException;

	/**
	 * 获取记录总数
	 * 
	 * @param sql
	 * @param params
	 * @return
	 * @throws SQLException
	 */
	public abstract int executeQueryCountSQL(String sql, Object[] params) throws SQLException;

	/**
	 * 查询指定条件SQL 分页
	 * 
	 * @param entityClass
	 * @param sql
	 * @param params
	 * @param pageSize
	 * @param pageNum
	 * @return
	 * @throws SQLException
	 */
	public abstract <T extends BaseEntity> List<T> executeQuerySQL(Class<T> entityClass, String sql, Object[] params, int pageSize, int pageNum)
	        throws SQLException;

	/**
	 * 获取结果集
	 * 
	 * @param entityClass
	 * @param sql
	 * @param params
	 * @param start
	 * @param end
	 * @return
	 */
	public abstract <T extends BaseEntity> List<T> queryForList(Class<T> entityClass, String sql, Object[] params, int start, int end);

	/**
	 * 获取记录总数
	 * 
	 * @param sql
	 * @param params
	 * @return
	 */
	public abstract int queryForCount(String sql, Object[] params);

	/**
	 * 生成特定数据库的sql分页语句
	 * 
	 * @param sql
	 * @return
	 */
	public abstract String getPagesSQL(String sql, int start, int end);

}
